package com.cinema.service.impl;

import com.cinema.dao.UserDao;
import com.cinema.entity.User;
import com.cinema.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserDao userDao;
    @Override
    //添加用户
    public int insertUser(User user) {
        //判断昵称是否重复
        User user1 = userDao.queryByMobile(user.getMobile());
        if (user1 == null){
            userDao.insertUser(user);
        }else {
            return -1;
        }
        return 1;
    }

    @Override
    public User queryUserByMobile(String mobile) {
        //通过mobile查询用户
       return userDao.queryByMobile(mobile);
    }

    @Override
    public int updatePsw(String mobile,String psw) {
       return userDao.updatePsw(mobile,psw);
    }
}
